package com.dynamixsoftware.printershare;

import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.app.Dialog;
import android.content.ActivityNotFoundException;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.Signature;
import android.content.res.AssetManager;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.BitmapFactory;
import android.graphics.BitmapFactory.Options;
import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.Paint;
import android.graphics.Paint.Style;
import android.graphics.Picture;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.provider.Settings.Secure;
import android.util.DisplayMetrics;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnFocusChangeListener;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.ImageView.ScaleType;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.RadioButton;
import android.widget.RelativeLayout;
import android.widget.RelativeLayout.LayoutParams;
import android.widget.TextView;
import android.widget.Toast;
import com.dynamixsoftware.printershare.data.DuplexMode;
import com.dynamixsoftware.printershare.data.Paper;
import com.dynamixsoftware.printershare.data.Printer;
import com.dynamixsoftware.printershare.data.PrintoutMode;
import com.dynamixsoftware.printershare.data.Tray;
import com.dynamixsoftware.printershare.data.User;
import com.flurry.android.FlurryAgent;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.security.Principal;
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Hashtable;
import java.util.List;
import java.util.Locale;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.Vector;

public abstract class ActivityPrint extends ActivityBase {
	protected static final int DIALOG_AUTHORIZATION = 2;
	protected static final int DIALOG_PAGES = 1;
	public static volatile Picture pp;
	private static int tsize = 150;
	protected DuplexMode duplexMode;
	private boolean end_exit;
	protected int margins = 2;
	protected CharSequence[] marginsOptions;
	protected boolean need_update_pages;
	protected int orientation = 0;
	protected CharSequence[] orientationOptions;
	protected Vector<Page> pages;
	protected Paper paper;
	protected PrintoutMode printoutMode;
	protected Handler progressHandler = new Handler() {
		public void handleMessage(Message paramAnonymousMessage) {
			switch (paramAnonymousMessage.what) {
			}
			for (;;) {
				super.handleMessage(paramAnonymousMessage);
				return;
				ActivityPrint.this.showProgress(paramAnonymousMessage.getData().getString("message"));
				continue;
				ActivityPrint.this.showProgress(paramAnonymousMessage.getData().getString("message"));
				continue;
				ActivityPrint.access$1102(ActivityPrint.this, null);
				App.freeMem();
				synchronized (ActivityPrint.this.tl_flag) {
					ActivityPrint.this.tl_flag[0] = 0;
					ActivityPrint.this.proceedCreateThumb(null);
					ActivityPrint.this.hideProgress();
					ActivityPrint.this.doOK();
				}
				ActivityPrint.access$1102(ActivityPrint.this, null);
				App.freeMem();
				synchronized (ActivityPrint.this.tl_flag) {
					ActivityPrint.this.tl_flag[0] = 0;
					ActivityPrint.this.proceedCreateThumb(null);
					ActivityPrint.this.hideProgress();
					ActivityPrint.this.last_error = paramAnonymousMessage.getData().getString("message");
					ActivityPrint.this.displayLastError(new DialogInterface.OnClickListener() {
						public void onClick(DialogInterface paramAnonymous2DialogInterface, int paramAnonymous2Int) {
						}
					});
				}
				ActivityPrint.access$1102(ActivityPrint.this, null);
				App.freeMem();
				synchronized (ActivityPrint.this.tl_flag) {
					ActivityPrint.this.tl_flag[0] = 0;
					ActivityPrint.this.proceedCreateThumb(null);
					ActivityPrint.this.hideProgress();
					ActivityPrint.this.showDialog(2);
				}
			}
		}
	};
	private Thread pt;
	private int sel_duplex;
	private int sel_margins;
	private int sel_mode;
	private int sel_orientation;
	private HashSet<Integer> sel_pages = new HashSet();
	private int sel_paper;
	private int sel_tray;
	private ArrayList<ImageView> tl = new ArrayList();
	private boolean[] tl_flag = new boolean[1];
	private Thread tl_thread;
	protected Tray tray;
	private Bitmap tst_bmp;
	private Thread ut;
	protected View view_dialog_authorization;
	protected View view_dialog_pages;

	private void doOK()
  {
    int k;
    label247:
    Hashtable localHashtable;
    if (!isFinishing())
    {
      String str3 = getResources().getConfiguration().locale.getLanguage();
      if ((this.tst_bmp == null) && (("en".equals(str3)) || ("it".equals(str3))) && ("".equals(getCampaignID())))
      {
        k = 1;
        if (k != 0)
        {
          int m = this.prefs.getInt("review_cf", 0);
          if ((m < 0) || (m > 30) || (m % 10 != 0)) {
            k = 0;
          }
          if ((m >= 0) && (m <= 30))
          {
            SharedPreferences.Editor localEditor = this.prefs.edit();
            localEditor.putInt("review_cf", m + 1);
            localEditor.commit();
          }
        }
        if (k == 0) {
          break label525;
        }
        String str4 = getResources().getString(2131099820) + "\n\n" + getResources().getString(2131099821);
        AlertDialog.Builder localBuilder2 = new AlertDialog.Builder(this);
        localBuilder2.setIcon(2130837549).setTitle("Tow Portal Print").setMessage(str4).setCancelable(false).setNegativeButton(2131099708, new DialogInterface.OnClickListener()
        {
          public void onClick(DialogInterface paramAnonymousDialogInterface, int paramAnonymousInt) {}
        }).show();
      }
    }
    else
    {
      str1 = "print_remote";
      localHashtable = new Hashtable();
      if (isPrinterLocal(printer.id)) {
        str1 = "print_local";
      }
      if (printer.id.endsWith("cloudprint.google.")) {
        str1 = "print_cloud";
      }
      if (this.tst_bmp != null) {
        if (this.tst_bmp.getWidth() != 1) {
          break label585;
        }
      }
    }
    label525:
    label585:
    for (String str1 = str1 + "_free";; str1 = str1 + "_test_page")
    {
      this.tst_bmp = null;
      if ((str1.startsWith("print_local")) && (printer.direct_address != null))
      {
        int j = printer.direct_address.indexOf("://");
        if (j > 0) {
          localHashtable.put("type", printer.direct_address.substring(0, j));
        }
      }
      try
      {
        PackageInfo localPackageInfo = getPackageManager().getPackageInfo(getPackageName(), 64);
        localObject = null;
        if (localPackageInfo != null)
        {
          Signature[] arrayOfSignature = localPackageInfo.signatures;
          localObject = null;
          if (arrayOfSignature != null)
          {
            int i = localPackageInfo.signatures.length;
            localObject = null;
            if (i > 0)
            {
              ByteArrayInputStream localByteArrayInputStream = new ByteArrayInputStream(localPackageInfo.signatures[0].toByteArray());
              String str2 = ((X509Certificate)CertificateFactory.getInstance("X509").generateCertificate(localByteArrayInputStream)).getIssuerDN().getName();
              localObject = str2;
            }
          }
        }
      }
      catch (Exception localException)
      {
        for (;;)
        {
          AlertDialog.Builder localBuilder1;
          localException.printStackTrace();
          App.reportThrowable(localException);
          Object localObject = null;
        }
      }
      if (localObject != null) {
        localHashtable.put("certname", localObject);
      }
      FlurryAgent.logEvent(str1, localHashtable);
      return;
      k = 0;
      break;
      if (isFinishing()) {
        break label247;
      }
      localBuilder1 = new AlertDialog.Builder(this);
      localBuilder1.setIcon(2130837549).setTitle("PrinterShare").setMessage(2131099820).setCancelable(false).setPositiveButton(2131099703, new DialogInterface.OnClickListener()
      {
        public void onClick(DialogInterface paramAnonymousDialogInterface, int paramAnonymousInt)
        {
          if (ActivityPrint.this.end_exit) {
            ActivityPrint.this.endOK();
          }
        }
      }).show();
      break label247;
    }
  }

	private void initPrinterParams()
  {
    this.paper = null;
    String str1 = this.prefs.getString(getActivityClassName() + "#paper", this.prefs.getString("paper", null));
    Locale localLocale = Locale.getDefault();
    String str2 = "A4";
    if ((localLocale.equals(Locale.CANADA)) || (localLocale.equals(Locale.CANADA_FRENCH)) || (localLocale.equals(Locale.US))) {
      str2 = "Letter";
    }
    int m;
    Paper localPaper;
    if (printer != null)
    {
      m = -1 + printer.papers.size();
      if (m >= 0)
      {
        localPaper = (Paper)printer.papers.elementAt(m);
        if (!localPaper.id.equals(str1)) {
          break label784;
        }
        this.paper = localPaper;
      }
    }
    if (this.paper == null)
    {
      if (!"A4".equals(str2)) {
        break label832;
      }
      this.paper = new Paper("", "A4", 2100, 2970, new Rect(0, 0, 2100, 2970));
      label205:
      this.paper.custom = true;
      if ((printer != null) && (printer.papers != null)) {
        printer.papers.add(0, this.paper);
      }
    }
    this.tray = null;
    String str3 = this.prefs.getString(getActivityClassName() + "#tray", this.prefs.getString("tray", null));
    int k;
    label313:
    Tray localTray;
    if (printer != null)
    {
      k = -1 + printer.trays.size();
      if (k >= 0)
      {
        localTray = (Tray)printer.trays.elementAt(k);
        if (!localTray.id.equals(str3)) {
          break label872;
        }
        this.tray = localTray;
      }
    }
    if (this.tray == null)
    {
      this.tray = new Tray();
      this.tray.id = "";
      this.tray.name = "Default Tray";
      if ((printer != null) && (printer.trays != null)) {
        printer.trays.add(0, this.tray);
      }
    }
    this.printoutMode = null;
    String str4 = this.prefs.getString(getActivityClassName() + "#mode", this.prefs.getString("mode", null));
    int j;
    label490:
    PrintoutMode localPrintoutMode;
    if (printer != null)
    {
      j = -1 + printer.printoutModes.size();
      if (j >= 0)
      {
        localPrintoutMode = (PrintoutMode)printer.printoutModes.elementAt(j);
        if (!localPrintoutMode.id.equals(str4)) {
          break label901;
        }
        this.printoutMode = localPrintoutMode;
      }
    }
    if (this.printoutMode == null)
    {
      this.printoutMode = new PrintoutMode();
      this.printoutMode.id = "";
      this.printoutMode.name = "Default";
      this.printoutMode.resolution = "150";
      if ((printer != null) && (printer.printoutModes != null)) {
        printer.printoutModes.add(0, this.printoutMode);
      }
    }
    this.duplexMode = null;
    String str5 = this.prefs.getString(getActivityClassName() + "#duplex", this.prefs.getString("duplex", null));
    if (printer != null) {}
    for (int i = -1 + printer.duplexModes.size();; i--)
    {
      DuplexMode localDuplexMode;
      if (i >= 0)
      {
        localDuplexMode = (DuplexMode)printer.duplexModes.elementAt(i);
        if (localDuplexMode.id.equals(str5)) {
          this.duplexMode = localDuplexMode;
        }
      }
      else
      {
        if (this.duplexMode == null)
        {
          this.duplexMode = new DuplexMode();
          this.duplexMode.id = "";
          this.duplexMode.name = "Off";
          if ((printer != null) && (printer.duplexModes != null)) {
            printer.duplexModes.add(0, this.duplexMode);
          }
        }
        return;
        label784:
        if (((localPaper.id.equals(printer.default_paper)) && (this.paper == null)) || (localPaper.id.equalsIgnoreCase(str2))) {
          this.paper = localPaper;
        }
        m--;
        break;
        label832:
        this.paper = new Paper("", "Letter", 2159, 2794, new Rect(0, 0, 2159, 2794));
        break label205;
        label872:
        if (localTray.id.equals(printer.default_tray)) {
          this.tray = localTray;
        }
        k--;
        break label313;
        label901:
        if (localPrintoutMode.id.equals(printer.default_printoutMode)) {
          this.printoutMode = localPrintoutMode;
        }
        j--;
        break label490;
      }
      if (localDuplexMode.id.equals(printer.default_duplexMode)) {
        this.duplexMode = localDuplexMode;
      }
    }
  }

	private void print(boolean paramBoolean) {
		if (!paramBoolean) {
			if (((RadioButton) this.view_dialog_pages.findViewById(2131230754)).isChecked()) {
				for (int i7 = 0; i7 < this.pages.size(); i7++) {
					((Page) this.pages.elementAt(i7)).print = true;
				}
				startPrint();
				return;
			}
			if (((RadioButton) this.view_dialog_pages.findViewById(2131230755)).isChecked()) {
				int i6 = 0;
				if (i6 < this.pages.size()) {
					if (this.sel_pages.contains(Integer.valueOf(i6))) {
					}
					for (((Page) this.pages.elementAt(i6)).print = true;; ((Page) this.pages.elementAt(i6)).print = false) {
						i6++;
						break;
					}
				}
				startPrint();
				return;
			}
			EditText localEditText = (EditText) this.view_dialog_pages.findViewById(2131230757);
			boolean[] arrayOfBoolean = new boolean[this.pages.size()];
			StringTokenizer localStringTokenizer = new StringTokenizer(localEditText.getText().toString(), ",");
			while (localStringTokenizer.hasMoreTokens()) {
				String str1 = localStringTokenizer.nextToken();
				String str2 = "";
				int k = str1.indexOf("-");
				if (k >= 0) {
					str2 = str1.substring(k + 1);
					str1 = str1.substring(0, k);
				}
				str1.trim();
				str2.trim();
				int m = str1.length();
				n = 0;
				if (m > 0) {
				}
				try {
					int i5 = Integer.parseInt(str1);
					n = i5;
				} catch (Exception localException2) {
					for (;;) {
						int i1;
						n = 0;
					}
				}
				i1 = str2.length();
				i2 = 0;
				if (i1 > 0) {
				}
				try {
					int i4 = Integer.parseInt(str2);
					i2 = i4;
				} catch (Exception localException1) {
					for (;;) {
						int i3;
						int i;
						int j;
						i2 = 0;
					}
				}
				if (n == 0) {
					n = i2;
				}
				if (i2 == 0) {
					i2 = n;
				}
				if ((n > 0) && (i2 >= n)) {
					for (i3 = n; i3 <= i2; i3++) {
						if (i3 - 1 < arrayOfBoolean.length) {
							arrayOfBoolean[(i3 - 1)] = true;
						}
					}
				}
			}
			i = 0;
			j = 0;
			if (j < this.pages.size()) {
				if (arrayOfBoolean[j] != 0) {
					((Page) this.pages.elementAt(j)).print = true;
					i++;
				}
				for (;;) {
					j++;
					break;
					((Page) this.pages.elementAt(j)).print = false;
				}
			}
			if (i > 0) {
				startPrint();
				return;
			}
			Toast.makeText(this, 2131099685, 1).show();
		} else {
			showDialog(1);
			return;
		}
	}

	private void printTestPage()
  {
    Vector localVector = new Vector();
    this.tst_bmp = null;
    for (int i = 0;; i++)
    {
      if (i < 3) {}
      try
      {
        localInputStream = getAssets().open("test_page.png");
      }
      catch (Exception localException)
      {
        for (;;)
        {
          InputStream localInputStream;
          BitmapFactory.Options localOptions;
          label82:
          int j;
          int k;
          Bitmap localBitmap1;
          int m;
          int n;
          Picture localPicture;
          Canvas localCanvas;
          int i1;
          int i2;
          Rect localRect1;
          int i3;
          Bitmap localBitmap2;
          Rect localRect2;
          Rect localRect3;
          Paint localPaint;
          Rect localRect4;
          Rect localRect5;
          Rect localRect6;
          Rect localRect7;
          Page localPage;
          localException.printStackTrace();
          this.last_error = ("Internal Error: " + localException.getMessage());
          App.reportThrowable(localException);
        }
        DialogInterface.OnClickListener local11 = new DialogInterface.OnClickListener()
        {
          public void onClick(DialogInterface paramAnonymousDialogInterface, int paramAnonymousInt) {}
        };
        displayLastError(local11);
        return;
      }
      try
      {
        App.freeMem();
        localOptions = new BitmapFactory.Options();
        localOptions.inPreferredConfig = Bitmap.Config.ARGB_8888;
        localOptions.inDither = false;
        if (i > 0) {
          localOptions.inSampleSize = (i * 2);
        }
        this.tst_bmp = BitmapFactory.decodeStream(localInputStream, null, localOptions);
      }
      catch (OutOfMemoryError localOutOfMemoryError)
      {
        break label82;
      }
      localInputStream.close();
      if (this.tst_bmp != null)
      {
        j = this.paper.width;
        k = this.paper.height;
        localBitmap1 = this.tst_bmp;
        m = 0;
        n = 0;
        if (localBitmap1 != null)
        {
          n = this.tst_bmp.getWidth();
          m = this.tst_bmp.getHeight();
        }
        localPicture = new Picture();
        localCanvas = localPicture.beginRecording(j, k);
        localCanvas.drawColor(-1);
        if (this.tst_bmp != null)
        {
          i1 = 1016;
          i2 = i1 * m / n;
          localRect1 = this.paper.image_area;
          i3 = 0;
          if (localRect1 != null)
          {
            i3 = this.paper.height - this.paper.image_area.bottom;
            if (this.paper.image_area.left > i3) {
              i3 = this.paper.image_area.left;
            }
          }
          if (j - i3 * 2 < i1)
          {
            i1 = j - i3 * 2;
            i2 = m * (j - i3 * 2) / n;
          }
          if (k - i3 * 2 < i2)
          {
            i2 = k - i3 * 2;
            i1 = n * (k - i3 * 2) / m;
          }
          localBitmap2 = this.tst_bmp;
          localRect2 = new Rect(0, 0, n, m);
          localRect3 = new Rect(i3, i3, i3 + i1, i3 + i2);
          localCanvas.drawBitmap(localBitmap2, localRect2, localRect3, App.newPaint());
          localPaint = App.newPaint();
          localPaint.setColor(-1);
          localPaint.setStyle(Paint.Style.FILL);
          localRect4 = new Rect(0, 0, j, i3);
          localCanvas.drawRect(localRect4, localPaint);
          localRect5 = new Rect(0, k - i3, j, k);
          localCanvas.drawRect(localRect5, localPaint);
          localRect6 = new Rect(0, 0, i3, k);
          localCanvas.drawRect(localRect6, localPaint);
          localRect7 = new Rect(j - i3, 0, j, k);
          localCanvas.drawRect(localRect7, localPaint);
        }
        localPicture.endRecording();
        localPage = new Page(localPicture);
        localVector.add(localPage);
        if (this.last_error != null) {
          break;
        }
        startPrintThread(localVector, 1, false);
        return;
      }
    }
  }

	/* Error */
	private void proceedCreateThumb(ImageView paramImageView) {
		// Byte code:
		// 0: aload_1
		// 1: ifnull +125 -> 126
		// 4: aload_1
		// 5: invokevirtual 769 android/widget/ImageView:getTag
		// ()Ljava/lang/Object;
		// 8: checkcast 575 java/lang/Integer
		// 11: invokevirtual 772 java/lang/Integer:intValue ()I
		// 14: istore 4
		// 16: aload_0
		// 17: getfield 84 com/dynamixsoftware/printershare/ActivityPrint:tl
		// Ljava/util/ArrayList;
		// 20: astore 5
		// 22: aload 5
		// 24: monitorenter
		// 25: iconst_m1
		// 26: istore 6
		// 28: iconst_0
		// 29: istore 7
		// 31: aload_0
		// 32: getfield 84 com/dynamixsoftware/printershare/ActivityPrint:tl
		// Ljava/util/ArrayList;
		// 35: invokevirtual 773 java/util/ArrayList:size ()I
		// 38: istore 9
		// 40: iconst_0
		// 41: istore 10
		// 43: iload 7
		// 45: iload 9
		// 47: if_icmpge +56 -> 103
		// 50: aload_0
		// 51: getfield 84 com/dynamixsoftware/printershare/ActivityPrint:tl
		// Ljava/util/ArrayList;
		// 54: iload 7
		// 56: invokevirtual 776 java/util/ArrayList:get (I)Ljava/lang/Object;
		// 59: checkcast 765 android/widget/ImageView
		// 62: astore 11
		// 64: aload 11
		// 66: invokevirtual 769 android/widget/ImageView:getTag
		// ()Ljava/lang/Object;
		// 69: checkcast 575 java/lang/Integer
		// 72: invokevirtual 772 java/lang/Integer:intValue ()I
		// 75: iload 4
		// 77: if_icmpge +7 -> 84
		// 80: iload 7
		// 82: istore 6
		// 84: aload 11
		// 86: aload_1
		// 87: if_acmpne +58 -> 145
		// 90: aload_0
		// 91: getfield 84 com/dynamixsoftware/printershare/ActivityPrint:tl
		// Ljava/util/ArrayList;
		// 94: iload 7
		// 96: invokevirtual 779 java/util/ArrayList:remove
		// (I)Ljava/lang/Object;
		// 99: pop
		// 100: iconst_1
		// 101: istore 10
		// 103: iload 6
		// 105: iconst_1
		// 106: iadd
		// 107: istore 13
		// 109: iload 10
		// 111: ifeq +40 -> 151
		// 114: aload_0
		// 115: getfield 84 com/dynamixsoftware/printershare/ActivityPrint:tl
		// Ljava/util/ArrayList;
		// 118: iconst_0
		// 119: aload_1
		// 120: invokevirtual 780 java/util/ArrayList:add (ILjava/lang/Object;)V
		// 123: aload 5
		// 125: monitorexit
		// 126: aload_0
		// 127: getfield 86
		// com/dynamixsoftware/printershare/ActivityPrint:tl_flag [Z
		// 130: astore_2
		// 131: aload_2
		// 132: monitorenter
		// 133: aload_0
		// 134: getfield 86
		// com/dynamixsoftware/printershare/ActivityPrint:tl_flag [Z
		// 137: iconst_0
		// 138: baload
		// 139: ifeq +33 -> 172
		// 142: aload_2
		// 143: monitorexit
		// 144: return
		// 145: iinc 7 1
		// 148: goto -117 -> 31
		// 151: aload_0
		// 152: getfield 84 com/dynamixsoftware/printershare/ActivityPrint:tl
		// Ljava/util/ArrayList;
		// 155: iload 13
		// 157: aload_1
		// 158: invokevirtual 780 java/util/ArrayList:add (ILjava/lang/Object;)V
		// 161: goto -38 -> 123
		// 164: astore 8
		// 166: aload 5
		// 168: monitorexit
		// 169: aload 8
		// 171: athrow
		// 172: aload_2
		// 173: monitorexit
		// 174: aload_0
		// 175: getfield 125
		// com/dynamixsoftware/printershare/ActivityPrint:tl_thread
		// Ljava/lang/Thread;
		// 178: ifnull +13 -> 191
		// 181: aload_0
		// 182: getfield 125
		// com/dynamixsoftware/printershare/ActivityPrint:tl_thread
		// Ljava/lang/Thread;
		// 185: invokevirtual 785 java/lang/Thread:isAlive ()Z
		// 188: ifne -44 -> 144
		// 191: aload_0
		// 192: new 787 com/dynamixsoftware/printershare/ActivityPrint$31
		// 195: dup
		// 196: aload_0
		// 197: invokespecial 788
		// com/dynamixsoftware/printershare/ActivityPrint$31:<init>
		// (Lcom/dynamixsoftware/printershare/ActivityPrint;)V
		// 200: putfield 125
		// com/dynamixsoftware/printershare/ActivityPrint:tl_thread
		// Ljava/lang/Thread;
		// 203: aload_0
		// 204: getfield 125
		// com/dynamixsoftware/printershare/ActivityPrint:tl_thread
		// Ljava/lang/Thread;
		// 207: invokevirtual 791 java/lang/Thread:start ()V
		// 210: return
		// 211: astore_3
		// 212: aload_2
		// 213: monitorexit
		// 214: aload_3
		// 215: athrow
		// Local variable table:
		// start length slot name signature
		// 0 216 0 this ActivityPrint
		// 0 216 1 paramImageView ImageView
		// 211 4 3 localObject1 Object
		// 14 64 4 i int
		// 20 147 5 localArrayList ArrayList
		// 26 81 6 j int
		// 29 117 7 k int
		// 164 6 8 localObject2 Object
		// 38 10 9 m int
		// 41 69 10 n int
		// 62 23 11 localImageView ImageView
		// 107 49 13 i1 int
		// Exception table:
		// from to target type
		// 31 40 164 finally
		// 50 80 164 finally
		// 90 100 164 finally
		// 114 123 164 finally
		// 123 126 164 finally
		// 151 161 164 finally
		// 166 169 164 finally
		// 133 144 211 finally
		// 172 174 211 finally
		// 212 214 211 finally
	}

	private void startPrint()
  {
    this.action.run(new Runnable()new Runnable
    {
      public void run()
      {
        if (ActivityPrint.this.isPrinterNearby(ActivityCore.printer.id))
        {
          int i = ActivityPrint.this.getFPC();
          AlertDialog.Builder localBuilder = new AlertDialog.Builder(ActivityPrint.this).setIcon(17301543);
          final Intent localIntent1;
          if (i == 0)
          {
            localBuilder.setTitle(2131099857);
            if ("barnesnobel".equals(ActivityPrint.this.getCampaignID()))
            {
              localBuilder.setMessage(2131099866);
              localIntent1 = new Intent();
              localIntent1.setAction("android.intent.action.VIEW");
              if (!"pdassi".equals(ActivityPrint.this.getCampaignID())) {
                break label502;
              }
              localIntent1.setData(Uri.parse("http://am.pdassi.de/123299"));
            }
          }
          label552:
          label559:
          label577:
          label583:
          for (;;)
          {
            int k;
            boolean bool2;
            boolean bool1;
            try
            {
              Intent.class.getMethod("setPackage", new Class[] { String.class }).invoke(localIntent1, new Object[] { "de.pdassi.android" });
              if (!"barnesnobel".equals(ActivityPrint.this.getCampaignID())) {
                break label552;
              }
              k = 2131099730;
              localBuilder.setPositiveButton(k, new DialogInterface.OnClickListener()
              {
                public void onClick(DialogInterface paramAnonymous2DialogInterface, int paramAnonymous2Int)
                {
                  ActivityPrint.this.startActivity(localIntent1);
                }
              });
              final Intent localIntent2 = new Intent();
              localIntent2.setAction("android.intent.action.VIEW");
              localIntent2.addCategory("android.intent.category.BROWSABLE");
              localIntent2.setData(Uri.parse("http://www.printershare.com/action?name=buy-android-key"));
              if (!"barnesnobel".equals(ActivityPrint.this.getCampaignID())) {
                localBuilder.setNeutralButton(2131099729, new DialogInterface.OnClickListener()
                {
                  public void onClick(DialogInterface paramAnonymous2DialogInterface, int paramAnonymous2Int)
                  {
                    ActivityPrint.this.startActivity(localIntent2);
                  }
                });
              }
              if (i != 0) {
                break label559;
              }
              localBuilder.setNegativeButton(2131099731, new DialogInterface.OnClickListener()
              {
                public void onClick(DialogInterface paramAnonymous2DialogInterface, int paramAnonymous2Int)
                {
                  ActivityPrint.this.printTestPage();
                }
              });
              List localList = ActivityPrint.this.getPackageManager().queryIntentActivities(localIntent1, 65536);
              AlertDialog localAlertDialog = localBuilder.show();
              if (!"barnesnobel".equals(ActivityPrint.this.getCampaignID()))
              {
                Button localButton2 = localAlertDialog.getButton(-1);
                if ((localList == null) || (localList.size() <= 0)) {
                  break label577;
                }
                bool2 = true;
                localButton2.setEnabled(bool2);
              }
              Button localButton1 = localAlertDialog.getButton(-3);
              if (localButton1 != null)
              {
                if (Settings.Secure.getInt(ActivityPrint.this.getContentResolver(), "install_non_market_apps", 0) <= 0) {
                  break label583;
                }
                bool1 = true;
                localButton1.setEnabled(bool1);
              }
              return;
              localBuilder.setMessage(2131099865);
              break;
              localBuilder.setTitle(2131099857);
              int j = ActivityPrint.this.getIFPC();
              if (j < i)
              {
                j = i;
                if (j % 5 > 0) {
                  j += 5 - j % 5;
                }
              }
              String str = ActivityPrint.this.getResources().getString(2131099864);
              Object[] arrayOfObject = new Object[2];
              arrayOfObject[0] = Integer.valueOf(j);
              arrayOfObject[1] = Integer.valueOf(i);
              localBuilder.setMessage(String.format(str, arrayOfObject));
            }
            catch (Exception localException)
            {
              localException.printStackTrace();
              App.reportThrowable(localException);
              continue;
            }
            label502:
            if ("barnesnobel".equals(ActivityPrint.this.getCampaignID()))
            {
              localIntent1.setAction("com.bn.sdk.shop.details");
              localIntent1.putExtra("product_details_ean", "2940043862990");
            }
            else
            {
              localIntent1.setData(Uri.parse("market://details?id=com.dynamixsoftware.printershare.premium"));
              continue;
              k = 2131099728;
              continue;
              localBuilder.setNegativeButton(2131099726, new DialogInterface.OnClickListener()
              {
                public void onClick(DialogInterface paramAnonymous2DialogInterface, int paramAnonymous2Int)
                {
                  ActivityPrint.access$302(ActivityPrint.this, Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888));
                  ActivityPrint.this.startPrintThread(ActivityPrint.this.pages);
                }
              });
              continue;
              bool2 = false;
              continue;
              bool1 = false;
            }
          }
        }
        ActivityPrint.this.startPrintThread(ActivityPrint.this.pages);
      }
    }, new Runnable()
    {
      public void run()
      {
        ActivityPrint.this.startPrintThread(ActivityPrint.this.pages);
      }
    });
  }

	private void startPrintThread(Vector<Page> paramVector, int paramInt, boolean paramBoolean)
  {
    this.end_exit = paramBoolean;
    synchronized (this.tl_flag)
    {
      this.tl_flag[0] = true;
    }
    synchronized (this.tl)
    {
      this.tl.clear();
      if (this.tl_thread != null) {
        while (this.tl_thread.isAlive())
        {
          try
          {
            Thread.sleep(100L);
          }
          catch (InterruptedException localInterruptedException) {}
          continue;
          localObject1 = finally;
          throw localObject1;
        }
      }
    }
    this.pt = new PrintThread(this, printer, this.paper, this.tray, this.printoutMode, this.duplexMode, paramVector, paramInt, this.progressHandler);
    this.pt.start();
  }

	protected abstract void createPages();

	protected void endOK() {
		this.pages = null;
		setResult(-1);
		finish();
	}

	protected void onActivityResult(int paramInt1, int paramInt2, Intent paramIntent) {
		if (paramInt1 == 999) {
			if (this.end_exit) {
				endOK();
			}
		}
		for (;;) {
			super.onActivityResult(paramInt1, paramInt2, paramIntent);
			return;
			if ((paramInt2 == -1) && ((paramInt1 == 1) || (paramInt1 == 2))) {
				this.need_update_pages = true;
				initPrinterParams();
			}
			if (paramInt1 != 10) {
				continue;
			}
			synchronized (this.tl_flag) {
				this.tl_flag[0] = false;
				proceedCreateThumb(null);
			}
		}
	}

	public void onCreate(Bundle paramBundle) {
		super.onCreate(paramBundle);
		Resources localResources = getResources();
		Configuration localConfiguration = localResources.getConfiguration();
		try {
			if ((0xF & ((Integer) localConfiguration.getClass().getField("screenLayout").get(localConfiguration))
					.intValue()) == 4) {
				tsize = 300;
			}
			label48: initPrinterParams();
			CharSequence[] arrayOfCharSequence1 = new CharSequence[3];
			arrayOfCharSequence1[0] = localResources.getString(2131099801);
			arrayOfCharSequence1[1] = localResources.getString(2131099802);
			arrayOfCharSequence1[2] = localResources.getString(2131099803);
			this.orientationOptions = arrayOfCharSequence1;
			this.orientation = this.prefs.getInt(getActivityClassName() + "#orientation", this.orientation);
			CharSequence[] arrayOfCharSequence2 = new CharSequence[4];
			arrayOfCharSequence2[0] = localResources.getString(2131099799);
			arrayOfCharSequence2[1] = "1/4\"";
			arrayOfCharSequence2[2] = "1/3\"";
			arrayOfCharSequence2[3] = "1/2\"";
			this.marginsOptions = arrayOfCharSequence2;
			this.margins = this.prefs.getInt(getActivityClassName() + "#margins", this.margins);
			setContentView(2130903063);
			setTitle(2131099678);
			findViewById(2131230794).setOnClickListener(new View.OnClickListener() {
				public void onClick(View paramAnonymousView) {
					ActivityPrint.this.print();
				}
			});
			findViewById(2131230795).setOnClickListener(new View.OnClickListener() {
				public void onClick(View paramAnonymousView) {
					ActivityPrint.this.findViewById(2131230797).showContextMenu();
				}
			});
			((LinearLayout) findViewById(2131230797)).setOnCreateContextMenuListener(this);
			this.need_update_pages = true;
			return;
		} catch (Exception localException) {
			for (;;) {
				localException.printStackTrace();
				App.reportThrowable(localException);
			}
		} catch (NoSuchFieldException localNoSuchFieldException) {
			break label48;
		}
	}

	public void onCreateContextMenu(ContextMenu paramContextMenu, View paramView,
			ContextMenu.ContextMenuInfo paramContextMenuInfo) {
		paramContextMenu.setHeaderTitle(getResources().getString(2131099789));
		paramContextMenu.add(0, 30, 0, 2131099798);
		paramContextMenu.add(0, 23, 0, 2131099800);
		paramContextMenu.add(0, 21, 0, 2131099804);
		paramContextMenu.add(0, 22, 0, 2131099805);
		paramContextMenu.add(0, 10, 0, 2131099806);
		paramContextMenu.add(0, 11, 0, 2131099807);
		paramContextMenu.add(0, 12, 0, 2131099651);
	}

	protected Dialog onCreateDialog(int paramInt) {
		LayoutInflater localLayoutInflater = LayoutInflater.from(this);
		switch (paramInt) {
		default:
			return null;
		case 1:
			this.view_dialog_pages = localLayoutInflater.inflate(2130903048, null);
			final EditText localEditText = (EditText) this.view_dialog_pages.findViewById(2131230751);
			localEditText.setFocusable(false);
			localEditText.setFocusableInTouchMode(false);
			localEditText.setClickable(false);
			localEditText.setKeyListener(null);
			localEditText.setInputType(0);
			((Button) this.view_dialog_pages.findViewById(2131230752)).setOnClickListener(new View.OnClickListener() {
				public void onClick(View paramAnonymousView) {
					int i = Integer.parseInt(localEditText.getText().toString());
					if (i < 10) {
						i++;
					}
					localEditText.setText(String.valueOf(i));
				}
			});
			((Button) this.view_dialog_pages.findViewById(2131230753)).setOnClickListener(new View.OnClickListener() {
				public void onClick(View paramAnonymousView) {
					int i = Integer.parseInt(localEditText.getText().toString());
					if (i > 1) {
						i--;
					}
					localEditText.setText(String.valueOf(i));
				}
			});
			((EditText) this.view_dialog_pages.findViewById(2131230757))
					.setOnFocusChangeListener(new View.OnFocusChangeListener() {
						public void onFocusChange(View paramAnonymousView, boolean paramAnonymousBoolean) {
							if (paramAnonymousBoolean) {
								((RadioButton) ActivityPrint.this.view_dialog_pages.findViewById(2131230756))
										.setChecked(true);
							}
						}
					});
			((RadioButton) this.view_dialog_pages.findViewById(2131230756))
					.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
						public void onCheckedChanged(CompoundButton paramAnonymousCompoundButton,
								boolean paramAnonymousBoolean) {
							if (paramAnonymousBoolean) {
								EditText localEditText = (EditText) ActivityPrint.this.view_dialog_pages
										.findViewById(2131230757);
								localEditText.requestFocus();
								localEditText.requestFocusFromTouch();
							}
							for (;;) {
								return;
								ActivityPrint.this.view_dialog_pages.requestFocus();
								try {
									InputMethodManager localInputMethodManager = (InputMethodManager) ActivityPrint.this
											.getSystemService("input_method");
									if (localInputMethodManager != null) {
										localInputMethodManager.hideSoftInputFromWindow(
												ActivityPrint.this.view_dialog_pages.getWindowToken(), 2);
										return;
									}
								} catch (Exception localException) {
									localException.printStackTrace();
									App.reportThrowable(localException);
								}
							}
						}
					});
			new AlertDialog.Builder(this).setIcon(2130837549).setTitle(2131099789).setView(this.view_dialog_pages)
					.setPositiveButton(2131099703, new DialogInterface.OnClickListener() {
						public void onClick(DialogInterface paramAnonymousDialogInterface, int paramAnonymousInt) {
							ActivityPrint.this.print(false);
						}
					}).setNegativeButton(2131099707, new DialogInterface.OnClickListener() {
						public void onClick(DialogInterface paramAnonymousDialogInterface, int paramAnonymousInt) {
						}
					}).create();
		}
		this.view_dialog_authorization = localLayoutInflater.inflate(2130903045, null);
		new AlertDialog.Builder(this).setIcon(17301543).setTitle(2131099841).setView(this.view_dialog_authorization)
				.setPositiveButton(2131099703, new DialogInterface.OnClickListener() {
					public void onClick(DialogInterface paramAnonymousDialogInterface, int paramAnonymousInt) {
						EditText localEditText1 = (EditText) ActivityPrint.this.view_dialog_authorization
								.findViewById(2131230739);
						ActivityCore.printer.owner.login = localEditText1.getText().toString();
						EditText localEditText2 = (EditText) ActivityPrint.this.view_dialog_authorization
								.findViewById(2131230741);
						ActivityCore.printer.owner.password = localEditText2.getText().toString();
						SharedPreferences.Editor localEditor = ActivityPrint.this.prefs.edit();
						localEditor.putString("printer_login", ActivityCore.printer.owner.login);
						localEditor.putString("printer_password", ActivityCore.printer.owner.password);
						localEditor.commit();
						ActivityPrint.this.print(false);
					}
				}).setNegativeButton(2131099707, new DialogInterface.OnClickListener() {
					public void onClick(DialogInterface paramAnonymousDialogInterface, int paramAnonymousInt) {
					}
				}).create();
	}

	public void onDestroy() {
		recyclePages();
		super.onDestroy();
	}

	public boolean onMenuItemSelected(int paramInt, MenuItem paramMenuItem) {
		switch (paramMenuItem.getItemId()) {
		default:
			return super.onMenuItemSelected(paramInt, paramMenuItem);
		case 10:
			AlertDialog.Builder localBuilder6 = new AlertDialog.Builder(this).setTitle(2131099806)
					.setPositiveButton(2131099703, new DialogInterface.OnClickListener() {
						public void onClick(DialogInterface paramAnonymousDialogInterface, int paramAnonymousInt) {
							if ((ActivityPrint.this.sel_mode < 0) || (ActivityCore.printer == null)
									|| (ActivityCore.printer.printoutModes.size() == 0)) {
								return;
							}
							ActivityPrint.this.printoutMode = ((PrintoutMode) ActivityCore.printer.printoutModes
									.elementAt(ActivityPrint.this.sel_mode));
							SharedPreferences.Editor localEditor = ActivityPrint.this.prefs.edit();
							localEditor.putString(ActivityPrint.this.getActivityClassName() + "#mode",
									ActivityPrint.this.printoutMode.id);
							localEditor.commit();
							ActivityPrint.this.update();
						}
					}).setNegativeButton(2131099707, null);
			int i2 = -1;
			CharSequence[] arrayOfCharSequence4;
			int i3;
			if ((printer != null) && (printer.printoutModes.size() > 0)) {
				arrayOfCharSequence4 = new CharSequence[printer.printoutModes.size()];
				i3 = 0;
			}
			while (i3 < printer.printoutModes.size()) {
				PrintoutMode localPrintoutMode = (PrintoutMode) printer.printoutModes.elementAt(i3);
				arrayOfCharSequence4[i3] = localPrintoutMode.name;
				if (this.printoutMode == localPrintoutMode) {
					i2 = i3;
				}
				i3++;
				continue;
				arrayOfCharSequence4 = new CharSequence[1];
				arrayOfCharSequence4[0] = this.printoutMode.name;
				i2 = 0;
			}
			this.sel_mode = i2;
			localBuilder6.setSingleChoiceItems(arrayOfCharSequence4, i2, new DialogInterface.OnClickListener() {
				public void onClick(DialogInterface paramAnonymousDialogInterface, int paramAnonymousInt) {
					ActivityPrint.access$502(ActivityPrint.this, paramAnonymousInt);
				}
			});
			localBuilder6.show();
			return true;
		case 11:
			AlertDialog.Builder localBuilder5 = new AlertDialog.Builder(this).setTitle(2131099807)
					.setPositiveButton(2131099703, new DialogInterface.OnClickListener() {
						public void onClick(DialogInterface paramAnonymousDialogInterface, int paramAnonymousInt) {
							if ((ActivityPrint.this.sel_duplex < 0) || (ActivityCore.printer == null)
									|| (ActivityCore.printer.duplexModes.size() == 0)) {
								return;
							}
							ActivityPrint.this.duplexMode = ((DuplexMode) ActivityCore.printer.duplexModes
									.elementAt(ActivityPrint.this.sel_duplex));
							SharedPreferences.Editor localEditor = ActivityPrint.this.prefs.edit();
							localEditor.putString(ActivityPrint.this.getActivityClassName() + "#duplex",
									ActivityPrint.this.duplexMode.id);
							localEditor.commit();
							ActivityPrint.this.update();
						}
					}).setNegativeButton(2131099707, null);
			int n = -1;
			CharSequence[] arrayOfCharSequence3;
			int i1;
			if ((printer != null) && (printer.duplexModes.size() > 0)) {
				arrayOfCharSequence3 = new CharSequence[printer.duplexModes.size()];
				i1 = 0;
			}
			while (i1 < printer.duplexModes.size()) {
				DuplexMode localDuplexMode = (DuplexMode) printer.duplexModes.elementAt(i1);
				arrayOfCharSequence3[i1] = localDuplexMode.name;
				if (this.duplexMode == localDuplexMode) {
					n = i1;
				}
				i1++;
				continue;
				arrayOfCharSequence3 = new CharSequence[1];
				arrayOfCharSequence3[0] = this.duplexMode.name;
				n = 0;
			}
			this.sel_duplex = n;
			localBuilder5.setSingleChoiceItems(arrayOfCharSequence3, n, new DialogInterface.OnClickListener() {
				public void onClick(DialogInterface paramAnonymousDialogInterface, int paramAnonymousInt) {
					ActivityPrint.access$602(ActivityPrint.this, paramAnonymousInt);
				}
			});
			localBuilder5.show();
			return true;
		case 12:
			this.printers_menu.show();
			return true;
		case 21:
			AlertDialog.Builder localBuilder4 = new AlertDialog.Builder(this).setTitle(2131099804)
					.setPositiveButton(2131099703, new DialogInterface.OnClickListener() {
						public void onClick(DialogInterface paramAnonymousDialogInterface, int paramAnonymousInt) {
							if ((ActivityPrint.this.sel_paper < 0) || (ActivityCore.printer == null)
									|| (ActivityCore.printer.papers.size() == 0)) {
								return;
							}
							ActivityPrint.this.paper = ((Paper) ActivityCore.printer.papers
									.elementAt(ActivityPrint.this.sel_paper));
							SharedPreferences.Editor localEditor = ActivityPrint.this.prefs.edit();
							localEditor.putString(ActivityPrint.this.getActivityClassName() + "#paper",
									ActivityPrint.this.paper.id);
							localEditor.commit();
							ActivityPrint.this.need_update_pages = true;
							ActivityPrint.this.update();
						}
					}).setNegativeButton(2131099707, null);
			int k = -1;
			CharSequence[] arrayOfCharSequence2;
			int m;
			if ((printer != null) && (printer.papers.size() > 0)) {
				arrayOfCharSequence2 = new CharSequence[printer.papers.size()];
				m = 0;
			}
			while (m < printer.papers.size()) {
				Paper localPaper = (Paper) printer.papers.elementAt(m);
				arrayOfCharSequence2[m] = localPaper.name;
				if (this.paper == localPaper) {
					k = m;
				}
				m++;
				continue;
				arrayOfCharSequence2 = new CharSequence[1];
				arrayOfCharSequence2[0] = this.paper.name;
				k = 0;
			}
			this.sel_paper = k;
			localBuilder4.setSingleChoiceItems(arrayOfCharSequence2, k, new DialogInterface.OnClickListener() {
				public void onClick(DialogInterface paramAnonymousDialogInterface, int paramAnonymousInt) {
					ActivityPrint.access$702(ActivityPrint.this, paramAnonymousInt);
				}
			});
			localBuilder4.show();
			return true;
		case 22:
			AlertDialog.Builder localBuilder3 = new AlertDialog.Builder(this).setTitle(2131099805)
					.setPositiveButton(2131099703, new DialogInterface.OnClickListener() {
						public void onClick(DialogInterface paramAnonymousDialogInterface, int paramAnonymousInt) {
							if ((ActivityPrint.this.sel_tray < 0) || (ActivityCore.printer == null)
									|| (ActivityCore.printer.trays.size() == 0)) {
								return;
							}
							ActivityPrint.this.tray = ((Tray) ActivityCore.printer.trays
									.elementAt(ActivityPrint.this.sel_tray));
							SharedPreferences.Editor localEditor = ActivityPrint.this.prefs.edit();
							localEditor.putString(ActivityPrint.this.getActivityClassName() + "#tray",
									ActivityPrint.this.tray.id);
							localEditor.commit();
							ActivityPrint.this.need_update_pages = false;
							ActivityPrint.this.update();
						}
					}).setNegativeButton(2131099707, null);
			int i = -1;
			CharSequence[] arrayOfCharSequence1;
			int j;
			if ((printer != null) && (printer.trays.size() > 0)) {
				arrayOfCharSequence1 = new CharSequence[printer.trays.size()];
				j = 0;
			}
			while (j < printer.trays.size()) {
				Tray localTray = (Tray) printer.trays.elementAt(j);
				arrayOfCharSequence1[j] = localTray.name;
				if (localTray == this.tray) {
					i = j;
				}
				j++;
				continue;
				arrayOfCharSequence1 = new CharSequence[1];
				arrayOfCharSequence1[0] = this.tray.name;
				i = 0;
			}
			this.sel_tray = i;
			localBuilder3.setSingleChoiceItems(arrayOfCharSequence1, i, new DialogInterface.OnClickListener() {
				public void onClick(DialogInterface paramAnonymousDialogInterface, int paramAnonymousInt) {
					ActivityPrint.access$802(ActivityPrint.this, paramAnonymousInt);
				}
			});
			localBuilder3.show();
			return true;
		case 23:
			AlertDialog.Builder localBuilder2 = new AlertDialog.Builder(this).setTitle(2131099800)
					.setPositiveButton(2131099703, new DialogInterface.OnClickListener() {
						public void onClick(DialogInterface paramAnonymousDialogInterface, int paramAnonymousInt) {
							ActivityPrint.this.orientation = ActivityPrint.this.sel_orientation;
							SharedPreferences.Editor localEditor = ActivityPrint.this.prefs.edit();
							localEditor.putInt(ActivityPrint.this.getActivityClassName() + "#orientation",
									ActivityPrint.this.orientation);
							localEditor.commit();
							ActivityPrint.this.need_update_pages = true;
							ActivityPrint.this.update();
						}
					}).setNegativeButton(2131099707, null);
			localBuilder2.setSingleChoiceItems(this.orientationOptions, this.orientation,
					new DialogInterface.OnClickListener() {
						public void onClick(DialogInterface paramAnonymousDialogInterface, int paramAnonymousInt) {
							ActivityPrint.access$902(ActivityPrint.this, paramAnonymousInt);
						}
					});
			this.sel_orientation = this.orientation;
			localBuilder2.show();
			return true;
		}
		AlertDialog.Builder localBuilder1 = new AlertDialog.Builder(this).setTitle(2131099798)
				.setPositiveButton(2131099703, new DialogInterface.OnClickListener() {
					public void onClick(DialogInterface paramAnonymousDialogInterface, int paramAnonymousInt) {
						ActivityPrint.this.margins = ActivityPrint.this.sel_margins;
						SharedPreferences.Editor localEditor = ActivityPrint.this.prefs.edit();
						localEditor.putInt(ActivityPrint.this.getActivityClassName() + "#margins",
								ActivityPrint.this.margins);
						localEditor.commit();
						ActivityPrint.this.need_update_pages = true;
						ActivityPrint.this.update();
					}
				}).setNegativeButton(2131099707, null);
		localBuilder1.setSingleChoiceItems(this.marginsOptions, this.margins, new DialogInterface.OnClickListener() {
			public void onClick(DialogInterface paramAnonymousDialogInterface, int paramAnonymousInt) {
				ActivityPrint.access$1002(ActivityPrint.this, paramAnonymousInt);
			}
		});
		this.sel_margins = this.margins;
		localBuilder1.show();
		return true;
	}

	protected void onPrepareDialog(int paramInt, Dialog paramDialog) {
		switch (paramInt) {
		default:
			return;
		case 1:
			RadioButton localRadioButton1 = (RadioButton) this.view_dialog_pages.findViewById(2131230754);
			RadioButton localRadioButton2 = (RadioButton) this.view_dialog_pages.findViewById(2131230755);
			if (this.sel_pages.size() == 0) {
				localRadioButton2.setEnabled(false);
				if (localRadioButton2.isChecked()) {
					localRadioButton1.setChecked(true);
				}
			}
			for (;;) {
				RadioButton localRadioButton3 = (RadioButton) this.view_dialog_pages.findViewById(2131230756);
				EditText localEditText2 = (EditText) this.view_dialog_pages.findViewById(2131230757);
				if ((localRadioButton3.isChecked()) && ("".equals(localEditText2.getText().toString()))) {
					localRadioButton1.setChecked(true);
				}
				this.view_dialog_pages.requestFocus();
				return;
				if (!localRadioButton2.isEnabled()) {
					localRadioButton2.setEnabled(true);
					localRadioButton2.setChecked(true);
				}
			}
		}
		EditText localEditText1 = (EditText) this.view_dialog_authorization.findViewById(2131230739);
		if (printer.owner.login != null) {
		}
		for (String str = printer.owner.login;; str = "") {
			localEditText1.setText(str);
			((EditText) this.view_dialog_authorization.findViewById(2131230741)).setText("");
			return;
		}
	}

	protected void print() {
		if (this.pages == null) {
			return;
		}
		if (printer == null) {
			this.printers_menu.show();
			return;
		}
		print(true);
	}

	protected final void recyclePages() {
		synchronized (this.tl) {
			this.tl.clear();
			for (;;) {
				if ((this.tl_thread != null) && (this.tl_thread.isAlive())) {
					try {
						Thread.sleep(100L);
					} catch (InterruptedException localInterruptedException) {
					}
				}
			}
		}
		if (this.pages != null) {
			this.pages.removeAllElements();
		}
		this.pages = null;
		this.sel_pages.clear();
		LinearLayout localLinearLayout = (LinearLayout) findViewById(2131230797);
		for (int i = 0; i < localLinearLayout.getChildCount(); i++) {
			ImageView localImageView = (ImageView) ((RelativeLayout) ((LinearLayout) localLinearLayout.getChildAt(i))
					.getChildAt(0)).getChildAt(0);
			localImageView.setImageDrawable(null);
			localImageView.setImageBitmap(null);
		}
		localLinearLayout.removeAllViews();
		App.freeMem();
		synchronized (this.tl_flag) {
			this.tl_flag[0] = false;
			return;
		}
	}

	protected final void showPages()
  {
    float f1 = getResources().getDisplayMetrics().density;
    TextView localTextView1 = (TextView)findViewById(2131230796);
    String str1;
    LinearLayout localLinearLayout1;
    int i;
    label96:
    LinearLayout localLinearLayout2;
    RelativeLayout localRelativeLayout;
    final ImageView localImageView;
    int j;
    if (this.pages != null)
    {
      String str3 = getResources().getString(2131099751);
      Object[] arrayOfObject = new Object[1];
      arrayOfObject[0] = Integer.valueOf(this.pages.size());
      str1 = String.format(str3, arrayOfObject);
      localTextView1.setText(str1);
      localLinearLayout1 = (LinearLayout)findViewById(2131230797);
      if (this.pages == null) {
        return;
      }
      i = 0;
      if (i >= this.pages.size()) {
        return;
      }
      localLinearLayout2 = new LinearLayout(this);
      localLinearLayout2.setOrientation(1);
      LinearLayout.LayoutParams localLayoutParams = new LinearLayout.LayoutParams(-2, -2);
      localLayoutParams.setMargins(0, (int)(5.0F * f1), (int)(15.0F * f1), (int)(5.0F * f1));
      localLinearLayout2.setLayoutParams(localLayoutParams);
      localRelativeLayout = new RelativeLayout(this);
      localRelativeLayout.setPadding(1, 1, 1, 1);
      localRelativeLayout.setBackgroundColor(-8355712);
      localImageView = new ImageView(this);
      localImageView.setId(2131230730);
      localImageView.setTag(Integer.valueOf(i));
      localImageView.setBackgroundColor(-1);
      localImageView.setAdjustViewBounds(true);
      Page localPage = (Page)this.pages.get(i);
      j = tsize;
      if (!localPage.landscape) {
        break label753;
      }
      k = (int)(f1 * j);
      if (this.paper.width <= this.paper.height) {
        break label724;
      }
    }
    label724:
    for (int m = (int)(f1 * j * this.paper.height / this.paper.width);; m = (int)(f1 * j * this.paper.width / this.paper.height))
    {
      if (m == 0) {
        m = k;
      }
      Picture localPicture = new Picture();
      Canvas localCanvas = localPicture.beginRecording(k, m);
      Paint localPaint = App.newPaint();
      localPaint.setColor(-16777216);
      String str2 = getResources().getString(2131099759);
      float f2 = localPaint.measureText(str2);
      float f3 = localPaint.getTextSize();
      localCanvas.drawText(str2, (k - f2) / 2.0F, (m - f3) / 2.0F, localPaint);
      localPicture.endRecording();
      localImageView.setMaxWidth(k);
      localImageView.setMaxHeight(m);
      localImageView.setScaleType(ImageView.ScaleType.FIT_CENTER);
      final int n = k;
      final int i1 = m;
      Drawable local32 = new Drawable()
      {
        boolean fl = false;
        
        public void draw(Canvas paramAnonymousCanvas)
        {
          Rect localRect = getBounds();
          paramAnonymousCanvas.save();
          paramAnonymousCanvas.clipRect(localRect);
          paramAnonymousCanvas.translate(localRect.left, localRect.top);
          Paint localPaint = App.newPaint();
          localPaint.setColor(-16777216);
          String str = ActivityPrint.this.getResources().getString(2131099759);
          float f1 = localPaint.measureText(str);
          float f2 = localPaint.getTextSize();
          paramAnonymousCanvas.drawText(str, (n - f1) / 2.0F, (i1 - f2) / 2.0F, localPaint);
          paramAnonymousCanvas.restore();
          if (!this.fl)
          {
            ActivityPrint.this.proceedCreateThumb(localImageView);
            this.fl = true;
          }
        }
        
        public int getIntrinsicHeight()
        {
          return i1;
        }
        
        public int getIntrinsicWidth()
        {
          return n;
        }
        
        public int getOpacity()
        {
          return -3;
        }
        
        public void setAlpha(int paramAnonymousInt) {}
        
        public void setColorFilter(ColorFilter paramAnonymousColorFilter) {}
      };
      localImageView.setImageDrawable(local32);
      View.OnClickListener local33 = new View.OnClickListener()
      {
        public void onClick(View paramAnonymousView)
        {
          ActivityPrint.Page localPage = (ActivityPrint.Page)ActivityPrint.this.pages.get(((Integer)paramAnonymousView.getTag()).intValue());
          synchronized (ActivityPrint.this.tl_flag)
          {
            ActivityPrint.this.tl_flag[0] = 1;
          }
          synchronized (ActivityPrint.this.tl)
          {
            ActivityPrint.this.tl.clear();
            if (ActivityPrint.this.tl_thread != null) {
              while (ActivityPrint.this.tl_thread.isAlive())
              {
                try
                {
                  Thread.sleep(100L);
                }
                catch (InterruptedException localInterruptedException) {}
                continue;
                localObject1 = finally;
                throw localObject1;
              }
            }
          }
          ActivityPrint.this.showPreview(localPage);
        }
      };
      localImageView.setOnClickListener(local33);
      localRelativeLayout.addView(localImageView, new RelativeLayout.LayoutParams(-2, -2));
      if (this.pages.size() > 1)
      {
        CheckBox localCheckBox = new CheckBox(this);
        localCheckBox.setButtonDrawable(2130837529);
        localCheckBox.setBackgroundColor(0);
        localCheckBox.setChecked(false);
        localCheckBox.setTag(Integer.valueOf(i));
        RelativeLayout.LayoutParams localLayoutParams1 = new RelativeLayout.LayoutParams(-2, -2);
        localLayoutParams1.addRule(5, 2131230730);
        localLayoutParams1.addRule(8, 2131230730);
        localCheckBox.setLayoutParams(localLayoutParams1);
        CompoundButton.OnCheckedChangeListener local34 = new CompoundButton.OnCheckedChangeListener()
        {
          public void onCheckedChanged(CompoundButton paramAnonymousCompoundButton, boolean paramAnonymousBoolean)
          {
            if (paramAnonymousBoolean) {
              ActivityPrint.this.sel_pages.add((Integer)paramAnonymousCompoundButton.getTag());
            }
            for (;;)
            {
              if (ActivityPrint.this.view_dialog_pages != null)
              {
                RadioButton localRadioButton = (RadioButton)ActivityPrint.this.view_dialog_pages.findViewById(2131230755);
                if (ActivityPrint.this.sel_pages.size() > 0)
                {
                  localRadioButton.setEnabled(true);
                  localRadioButton.setChecked(true);
                }
              }
              return;
              ActivityPrint.this.sel_pages.remove((Integer)paramAnonymousCompoundButton.getTag());
            }
          }
        };
        localCheckBox.setOnCheckedChangeListener(local34);
        localCheckBox.setTag(Integer.valueOf(i));
        localRelativeLayout.addView(localCheckBox);
      }
      localLinearLayout2.addView(localRelativeLayout, new LinearLayout.LayoutParams(-2, -2));
      TextView localTextView2 = new TextView(this);
      localTextView2.setTextSize(12.0F);
      localTextView2.setTextColor(-14671840);
      localTextView2.setText(String.valueOf(i + 1));
      localTextView2.setGravity(17);
      localLinearLayout2.addView(localTextView2, new LinearLayout.LayoutParams(-1, -2));
      localLinearLayout1.addView(localLinearLayout2);
      i++;
      break label96;
      str1 = "";
      break;
    }
    label753:
    if (this.paper.width > this.paper.height) {}
    for (int k = (int)(f1 * j * this.paper.height / this.paper.width);; k = (int)(f1 * j * this.paper.width / this.paper.height))
    {
      m = (int)(f1 * j);
      if (k != 0) {
        break;
      }
      k = m;
      break;
    }
  }

	protected void showPreview(Page paramPage) {
		pp = paramPage.getPicture();
		Intent localIntent = new Intent();
		localIntent.setClass(this, ActivityPreview.class);
		startActivityForResult(localIntent, 10);
	}

	protected void startPrintThread(Vector<Page> paramVector) {
		int i = Integer.parseInt(((EditText) this.view_dialog_pages.findViewById(2131230751)).getText().toString());
		if (i < 1) {
			i = 1;
		}
		startPrintThread(paramVector, i, true);
	}

	protected void update()
  {
    super.update();
    TextView localTextView1 = (TextView)findViewById(2131230791);
    String str1;
    String str2;
    label62:
    int i;
    label92:
    int j;
    if (this.paper != null)
    {
      str1 = this.paper.name;
      localTextView1.setText(str1);
      TextView localTextView2 = (TextView)findViewById(2131230792);
      if (this.tray == null) {
        break label186;
      }
      str2 = this.tray.name;
      localTextView2.setText(str2);
      ImageView localImageView = (ImageView)findViewById(2131230790);
      if (this.orientation != 0) {
        break label193;
      }
      i = 2130837554;
      localImageView.setBackgroundResource(i);
      if (this.need_update_pages)
      {
        this.need_update_pages = false;
        if (this.pages == null) {
          break label217;
        }
        j = this.pages.size();
        label127:
        updatePages();
        if (this.pages == null) {
          break label223;
        }
      }
    }
    label186:
    label193:
    label217:
    label223:
    for (int k = this.pages.size();; k = 0)
    {
      if ((j != k) && (this.view_dialog_pages != null)) {
        ((EditText)this.view_dialog_pages.findViewById(2131230757)).setText("");
      }
      return;
      str1 = "";
      break;
      str2 = "";
      break label62;
      if (this.orientation == 1)
      {
        i = 2130837556;
        break label92;
      }
      i = 2130837555;
      break label92;
      j = 0;
      break label127;
    }
  }

	protected final void updatePages() {
		showProgress(getResources().getString(2131099746));
		recyclePages();
		this.ut = new Thread() {
			public void run() {
				ActivityPrint.this.createPages();
				ActivityPrint.this.runOnUiThread(new Runnable() {
					public void run() {
						ActivityPrint.this.showPages();
						App.freeMem();
						ActivityPrint.this.hideProgress();
					}
				});
				ActivityPrint.access$1502(ActivityPrint.this, null);
			}
		};
		this.ut.start();
	}

	public static class Page {
		public boolean landscape;
		private Picture picture;
		public boolean print;
		public boolean printed;

		public Page(Picture paramPicture) {
			this.print = bool;
			this.printed = false;
			this.landscape = false;
			this.picture = paramPicture;
			if (paramPicture.getWidth() > paramPicture.getHeight()) {
			}
			for (;;) {
				this.landscape = bool;
				return;
				bool = false;
			}
		}

		public Page(boolean paramBoolean) {
			this.print = true;
			this.printed = false;
			this.landscape = false;
			this.landscape = paramBoolean;
		}

		final Bitmap createThumb() {
			float f = Resources.getSystem().getDisplayMetrics().density;
			Picture localPicture = getPicture();
			if (localPicture == null) {
				return null;
			}
			int i = ActivityPrint.tsize;
			int j;
			int k;
			if (localPicture.getWidth() > localPicture.getHeight()) {
				j = (int) (f * i);
				k = (int) (f * i * localPicture.getHeight() / localPicture.getWidth());
				if (k == 0) {
					k = j;
				}
			}
			for (;;) {
				int m = 0;
				Object localObject = null;
				if (m < 3) {
				}
				try {
					App.freeMem();
					Bitmap localBitmap = Bitmap.createBitmap(j, k, Bitmap.Config.ARGB_8888);
					localObject = localBitmap;
					new App.PCanvas(localObject).drawPicture(localPicture, new Rect(0, 0, j, k));
					return localObject;
					j = (int) (f * i * localPicture.getWidth() / localPicture.getHeight());
					k = (int) (f * i);
					if (j != 0) {
						continue;
					}
					j = k;
				} catch (OutOfMemoryError localOutOfMemoryError) {
					if (m == 1) {
						App.clearExternalBytesAllocated();
					}
					while (m != 2) {
						m++;
						break;
					}
					throw localOutOfMemoryError;
				}
			}
		}

		public Picture getPicture() {
			return this.picture;
		}
	}
}

/*
 * Location:
 * C:\Users\Admin\Desktop\Decompiler\JAD\jd-gui-0.3.6.windows\classes_dex2jar
 * .jar
 * 
 * Qualified Name: com.dynamixsoftware.printershare.ActivityPrint
 * 
 * JD-Core Version: 0.7.0.1
 */